import acroMLClassMethod from './acroML.ClassMethod.mjs';

function t_Table(t,instWrap){
  //console.log('t_Table',instWrap);
  let inst=instWrap.$;
  if (inst.props.columns){
    for(let i=0;i<inst.props.columns.length;i++){
      let column=inst.props.columns[i];
      acroMLClassMethod.translateProp(t,column,'title');
    }
  }
  acroMLClassMethod.translateProps(t,inst.props.locale);
  inst.props.locale={...inst.props.locale};
}

function t_PageHeader(t,instWrap){
  //console.log(instWrap);
  let inst=instWrap.$;
  acroMLClassMethod.translateProps(t,inst.props,['title','subTitle']);
}
function t_Statistic(t,instWrap){
  //console.log(instWrap);
  let inst=instWrap.$;
  acroMLClassMethod.translateProps(t,inst.props,['title']);
}
function t_Empty(t,instWrap){
  //console.log(instWrap);
  let inst=instWrap.$;
  acroMLClassMethod.translateProps(t,inst.props,['description']);
}
function t_Tooltip(t,instWrap){
  console.log('t_Tooltip',instWrap);
  //console.log(yjUtils.object2Str(instWrap.$));
  let inst=instWrap.$;
  //console.log(inst.props.title);
  /**
   * 用title属性写的，可以翻译
   * <Tooltip title='Edit'>
        Tooltip will show when mouse enter.
      </Tooltip>
   */
  if (inst.props.title){
    acroMLClassMethod.translateProps(t,inst.props,['title']);
  }
  /**
   * 用slot写的，不知道如何翻译。用TooltipContent翻译。
   * <Tooltip>
        <template #title>File</template>
        Tooltip will show when mouse enter.
      </Tooltip>
   */
  let slotTitle=instWrap.$slots.title;
  if (slotTitle){
    let k=slotTitle();
    //console.log(k);
    // k[0].children='aaa';
  }
}

function t_Menu(t,instWrap){
  let inst=instWrap.$;
  let items=inst.props.items;
  function transItems(items){
    for(let i=0;i<items.length;i++){
      let item=items[i];
      acroMLClassMethod.translateProps(t,item,['label','title']);
      if (item.children) transItems(item.children);
    }
  }
  if (items) transItems(items);
}
function t_Input(t,instWrap){
  let inst=instWrap.$;
  acroMLClassMethod.translateProps(t,inst.props,['placeholder']);
}
function t_Rate(t,instWrap){
  let inst=instWrap.$;
  let tooltips=inst.props.tooltips;
  if (tooltips) acroMLClassMethod.translateArray(t,tooltips);
}

acroMLClassMethod.register('ATable',t_Table);
acroMLClassMethod.register('AButton',acroMLClassMethod.t_element);
acroMLClassMethod.register('ATag',acroMLClassMethod.t_element);
acroMLClassMethod.register('ACheckbox',acroMLClassMethod.t_element);
acroMLClassMethod.register('ARadio',acroMLClassMethod.t_element);
// acroMLClassMethod.register('ATooltip',t_Tooltip);
/**
 * ant-design-vue v4.2.3，可能是笔误，TooltipContent没加前缀A
 */
acroMLClassMethod.register('TooltipContent',acroMLClassMethod.t_element);
acroMLClassMethod.register('ATimelineItem',acroMLClassMethod.t_element);
acroMLClassMethod.register('APageHeader',t_PageHeader);
acroMLClassMethod.register('AStatistic',t_Statistic);
acroMLClassMethod.register('AEmpty',t_Empty);
acroMLClassMethod.register('AMenu',t_Menu);
acroMLClassMethod.register('AInput',t_Input);
acroMLClassMethod.register('ARate',t_Rate);

export default {t_Table}
export {t_Table}